package org.datastreamapi.transform

import org.FlinkStreamApp
import org.apache.flink.api.common.functions.FilterFunction
import org.apache.flink.streaming.api.scala._

/**
 * description ：转换-filter
 * author      ：剧情再美终是戏 
 * mail        : 13286520398@163.com
 * date        ：Created in 2020/2/21 19:39
 * modified By ：
 * version:    : 1.0
 */
object Filter extends FlinkStreamApp {

  override def doSomeThing(environment: StreamExecutionEnvironment) = {
    // 创建数据
    val source = environment.fromElements(1, 2, 3)

    // 转换 匿名函数
    //source.filter(_ > 1).print

    // 转换 接口方式
    source.filter(new MyFilterFunction).print
  }

  class MyFilterFunction extends FilterFunction[Int] {
    override def filter(t: Int) = t > 2
  }

}
